
      // 封装存储  @==}}=====>>  你当前存储数据的时间
     export function setlocalstorage(key: string,data: {
             // 封装存储  @==}}=====>>  你当前存储数据的时间
             name // 封装存储  @==}}=====>>  你当前存储数据的时间
             : string; age: number;
         }[]){
            // 获取当前的时间
            let FirstTime = new Date().getTime();
            // 将当前时间存储本地
           return localStorage.setItem(key,JSON.stringify({
                data,
                time:FirstTime
            })) 
        }
        // 模拟接口数据
       let data = [{ name:"lww",age:19},{name:"mtl",age:18}];
		
       setlocalstorage("obj",data);
      function  getlocalstorage(key: string,Exp: number){
         let data = localStorage.getItem(key) as any;
         let newdata =JSON.parse(data);
         if(!data){return;};
         if(new Date().getTime() - newdata.time >Exp ){
             console.log("过期了");
             localStorage.removeItem(key);
             return;
         }else{
             console.log("没有过期");
             return;
         }
      }
    // 设置过期时间 
    let remenber = document.querySelector(".box") as any;
        remenber.addEventListener("click", () => {
            getlocalstorage("obj",5000);
        })
   
